﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tilver.Coder.Core
{
    /// <summary>
    /// 枚举子项
    /// </summary>
    [Serializable]
    public class CoderEnumItem
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 内部使用名称
        /// </summary>
        public string CodeName { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 描述信息
        /// </summary>
        public string Description { get; set; }

        public override int GetHashCode()
        {
            return string.IsNullOrEmpty(Name) ? 0 : Name.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj != null && obj is CoderEnum)
            {
                var another = obj as CoderEnum;
                if (Name == null)
                    return another.Name == null;
                else
                    return Name.Equals(another.Name, StringComparison.CurrentCulture);
            }
            else
                return base.Equals(obj);
        }
    }
}
